<template>
	<view class="mainbgc mainpadding">
		<view class="mainpadding ffffff radius margin_top">
			<view class="flexbetween">
				<view class="ershib flex1">积分数</view>
				<input class="huisetext textright" type="number" placeholder="请输入需要转换为余额的积分数" v-model="score">
			</view>
		</view>
		<view class="mainpadding ffffff radius margin_top">
			<view class="flexbetween">
				<view class="ershib flex1">积分余额</view>
				<view class="huangsetext">{{resdata.score}}</view>
			</view>
		</view>
		<view class="mainpadding huangsetext flexleft">
			<view class="">备注：{{resbeizhu.score_txsm}}</view>
		
		</view>
		<view class="gudingdb" @click="submit">
			<view class="bigbtn">确认转换</view>
		</view>
	</view>
</template>

<script>
	 const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				score:'',
				resdata:{},
				resbeizhu:{}
			}
		},
		onShow() {
			this.index()
			this.beizhu()
		},
		methods: {
			beizhu(){//转换备注
			let _this=this
				httpRequest.request('/api/index/getConfigInfo','GET',{}).then(res=>{
					_this.resbeizhu=res.data
				})
			},
			index(){//用户信息
			        httpRequest.request('/api/user/index','GET',{}).then(res=>{
						this.resdata=res.data
					})	
			},
			submit() {//积分提现
				let _this=this
				if (this.score == "" || this.score == 0) {
					httpRequest.toast("请输入转换数量")
					return
				}
				httpRequest.modal('提示', '确认要积分提现吗？', true, (res) => {
					if (res) {
						let data = {
							integral_price: this.score,
						}
						httpRequest.request('/api/user/scoreToPrice', 'GET', {
							score:_this.score,
							}, false, false, true).then(res => {
							httpRequest.toast(res.msg);
							if (res.code == 1) {
								setTimeout(() => {
									uni.navigateBack(1)
								}, 1000)
							}
						}).catch(err => {
							httpRequest.toast(err.msg);
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.textright{
		flex: 4;
	}
	.flex1{
		flex: 1;
	}
	.xiahuax {
		padding-bottom: 30rpx;
		border-bottom: 2rpx solid rgba(0, 0, 0, 0.05);
	}

	.noershib {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.huangsetext {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FD463E;
	}

	.huisetext {
		width: 50%;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333;
	}

	.ershib {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}
</style>
